<?php
namespace app\api\model;
use think\Model;

class TeamIncome extends Model{
    protected $type = [
        'id'            =>'integer',
        'type'            =>'integer',
        'is_review'    =>  'integer',
        'sell_price' => 'float',
        'kind_id' =>'integer', 
        'num'=>'integer',
        'client_id'=>'integer',
        'salesman_id'=>'integer',
        'parent_id'=>'integer'       
    ];
    //关联收入表
    public function client(){
        return $this->hasOne('client','id','client_id')->field('id,company_name');
    }
    public function guest(){
        return $this->hasOne('guest','id','guest_id')->field('id,guest_name');
    }
    public function kind(){
        return $this->hasOne('category','id','kind_id')->field('id,title');
    } 
    public function salesman(){
        return $this->hasOne('manager','id','salesman_id')->field('id,cn_name');
    } 
    public function receipts(){
        return $this->hasMany('Receipt','income_id','id')->field('id,income_id,money,type,in');
    } 
    public function team(){
        return $this->hasOne('Team','id','parent_id')->field('id,sn,title,start_date,operator_id');
    }
    public function inInvoices(){
        return $this->hasMany('InInvoices','income_id','id')->field('company_name,invoice_date,invoice_price,type,inout,income_id');
    }
}